package com.mine.app;

import com.mine.common.URL;
import com.mine.protocol.HttpServer;
import com.mine.register.LocalServiceRegister;
import com.mine.register.ServerRegister;
import com.mine.service.impl.HelloService;
import com.mine.service.impl.HelloServiceImpl;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author weixiao
 * @date 2025/3/31 10:56
 */
public class ProviderApp {

    public static void main(String[] args) throws IOException {
        LocalServiceRegister.put(HelloService.class.getName(), "1.0", HelloServiceImpl.class);
        // 服务注册
        Properties properties = new Properties();
        InputStream in = ProviderApp.class.getClassLoader().getResourceAsStream("application.properties");
        properties.load(in);
        String hostname = properties.getProperty("hostname");
        Integer port = Integer.parseInt(properties.getProperty("port"));
        URL url = new URL(hostname, port);
        ServerRegister.register(HelloService.class.getName(), url);
        // 服务启动
        HttpServer.start(hostname, port);
    }
}
